package bean;

public class Pagination {
	  private int page = 1;       // 页号
	  private int pageSize = 4;  // 每页大小
	  private int prePage = 1;    // 上页页号
	  private int nextPage = 2;   // 下页页号
	  private int startRow = 0;   // 起始行(从0开始)
	  private int maxPage = Integer.MAX_VALUE;  // 最大页号
	  
	  public int getPage() {
	    return page;
	  }
	  public void setPage(int page) {
	    this.page = page;
	    if(this.page <= 0) this.page=1;
	    if(this.page > maxPage) this.page = maxPage;
	    
	    // prePage, nextPage, startRow 要随 page 改变
	    prePage = this.page==1?1:this.page-1;
	    nextPage = this.page==maxPage?maxPage:this.page+1;
	    startRow = (this.page-1)*pageSize;
	  }
	  public int getPageSize() {
	    return pageSize;
	  }
	  public void setPageSize(int pageSize) {
	    this.pageSize = pageSize;
	  }
	  public int getPrePage() {
	    return prePage;
	  }
	  public void setPrePage(int prePage) {
	    this.prePage = prePage;
	  }
	  public int getNextPage() {
	    return nextPage;
	  }
	  public void setNextPage(int nextPage) {
	    this.nextPage = nextPage;
	  }
	  public int getStartRow() {
	    return startRow;
	  }
	  public void setStartRow(int startRow) {
	    this.startRow = startRow;
	  }
	  public int getMaxPage() {
	    return maxPage;
	  }
	  public void setMaxPage(int maxPage) {
	    this.maxPage = maxPage;
	    if(this.maxPage<=0) this.maxPage = 1;
	    
	    // nextPage 要随 maxPage 改变
	    nextPage = this.page==maxPage?maxPage:this.page+1;
	  }
}
